/**
 * 
 */
package cn.sdhuijin.vms.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateUtils;

/**
 * 请假条
 * 
 * @author 武继明
 * @since 2013年10月22日 下午4:43:04
 *
 */
@Entity
@Table(name = "t_leave")
public class Leave extends IdEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * messageId 简单ID 用于简化短信审批操作
	 */
	private Long messageId;
	@OneToOne
	@JoinColumn(name = "leave_message_id")
	private Message leaveMessage;
	@OneToOne
	@JoinColumn(name = "approve_message_id")
	private Message approveMessage;
	@ManyToOne
	@JoinColumn(name = "person_id")
	private Person person;// 请假人

	private String reason = "";// 事由

	private Date date = new Date();
	@Column(name = "start_time")
	private Date startTime = new Date();

	@Column(name = "end_time")
	private Date endTime = DateUtils.addHours(new Date(), 2);

	@Enumerated(EnumType.STRING)
	private ApproveStatus status = ApproveStatus.UNTREATED;

	@Column(name = "approve_time")
	private Date approveTime;// 审批时间

	@ManyToOne
	@JoinColumn(name = "approve_person_id")
	private User approvePerson;// 审批人

	public Long getMessageId() {
		return messageId;
	}

	public void setMessageId(Long messageId) {
		this.messageId = messageId;
	}

	public Message getLeaveMessage() {
		return leaveMessage;
	}

	public void setLeaveMessage(Message leaveMessage) {
		this.leaveMessage = leaveMessage;
	}

	public Message getApproveMessage() {
		return approveMessage;
	}

	public void setApproveMessage(Message approveMessage) {
		this.approveMessage = approveMessage;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public ApproveStatus getStatus() {
		return status;
	}

	public void setStatus(ApproveStatus status) {
		this.status = status;
	}

	public Date getApproveTime() {
		return approveTime;
	}

	public void setApproveTime(Date approveTime) {
		this.approveTime = approveTime;
	}

	public User getApprovePerson() {
		return approvePerson;
	}

	public void setApprovePerson(User approvePerson) {
		this.approvePerson = approvePerson;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

}
